package br.uece.laconi.tac.fuzzy.functions;

public class LinearFunction extends GenericFunction {

	float coeff;
	float constant;
	
	public LinearFunction() {
		this.coeff = 0f;
		this.constant = 0f;
	}
	
	public LinearFunction(float a, float b) {
		this.coeff = a;
		this.constant = b;
	}
	
	@Override
	public Float calculate(float[] var) {		
		return coeff*var[0] + constant;
	}

	public LinearFunction autoMake(float x1, float y1, float x2, float y2) {
		coeff = (y1 - y2) / (x1 - x2);
		constant = y2 - (x2*coeff);
		return this;
	}	
}
